
// convenience shortcut for getElementById()
//function $(strId){
//    return document.getElementById(strId);
//}

// simple debug output for Firefox & Firebug
var userAgent = navigator.userAgent.toLowerCase();
var isFirefox = userAgent.search("firefox") > 0 ? 1 : 0;
function debug(s) {
    if(isFirefox)
        console.debug(s);
}

// make tab links call onTabClick()
function associateTabClicks() {
    var tabs = $('navlist').getElementsByTagName('a');
    for(var i=0; i < tabs.length; i++) {
        var t = tabs[i];
        t.onclick = function() {
            onTabClick(this);
            return false;
        }
    }
}
//onclick="onTabClick(this)"


// returns the next element sibling
// (can't just use elem.nextSibling, because in Firefox, it returns whitespace
function getNextSibling(n) {
  var x = n.nextSibling;
  while (x && x.nodeType != 1) {
    x = x.nextSibling;
   }
  return x;
}

// called when tab clicked
function onTabClick(e) {
    // highlight tab (ei voi childNodes, tulee newlineja!
    var tabs = $('navlist').getElementsByTagName('li');
    // ei voi ottaa, tulee kaikki divit!
    // divs = $('content').getElementsByTagName('div');
    var div = $('content').getElementsByTagName('div')[0];

    for(var i=0; i < tabs.length; i++) {
        var obj = tabs[i].firstChild;
        var cl = "";
        if (e == obj)
            cl = "current";
        obj.className = cl;
        var disp = "none";
        if (cl != "")
            disp = "block";
        div.style.display = disp;
        // get the sibling div (not any divs underneath)
        div = getNextSibling(div);
    }
}
// called when the page has been loaded
function myonLoad() {
    associateTabClicks();
	prettyPrint();  // from prettify.js
//	initWidget();
}

